<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <title>资讯管理</title>
</head>
<style>
   table th{
        text-align: center;
    }
</style>
<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row  m-t-sm">
            <div class="col-lg-12">
                <ol class="breadcrumb f-fl">
                    <li>
                        <i class="fa fa-location-arrow"></i> <a>资讯管理</a>
                    </li>
                    <li class="active">
                        <strong>资讯列表</strong>
                    </li>
                </ol>
                <span class="navbar-right  m-r m-t-8"><a href="${ctx}/admin/info/edit?" class="btn-primary btn-add "> <i class='fa fa-plus-square-o'></i> 新 增</a></span>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox">
                        <div class="ibox-content">
                            <div class="search-area">
                                <form role="form" class="form-inline" id="queryform">
                                    <label for="title">
                                        <input type="input" placeholder="资讯标题" name="title"
                                               id="title"
                                               class="form-control form-filter">
                                    </label>
                                    <label for="classifyId">
                                            <select class="form-control form-filter" name="classifyId" id="classifyId">
                                                <option value="">选择类型</option>
                                                <c:forEach items="${cList}" var="citem">
                                                    <option value="${citem.id}">${citem.title}</option>
                                                </c:forEach>
                                            </select></label>
                                    <label for="srcId">
                                        <select class="form-control form-filter" name="srcId" id="srcId">
                                            <option value="">选择来源</option>
                                            <c:forEach items="${sList}" var="sitem">
                                                <option value="${sitem.id}">${sitem.title}</option>
                                            </c:forEach>
                                        </select>
                                    </label>


                                    <button class="btn btn-primary" id="btnSearch" type="button" onclick="submitFilter()" > 查询</button>
                                    <button class="btn btn-primary" datatable-clear type="button"> 清除</button>
                                </form>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover dataTables" id="data-table"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>


<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {
        var setting = {
            "ajax": {
                "url": "${ctx}/admin/info/list",
                "type": "POST"
            },
            "columns": [
                {"title": "图片", "data": "image", "width": "6%", "orderable": false},
                {"title": "资讯标题", "data": "title", "width": "14%", "orderable": false},
                {"title": "资讯类型", "data": "classify", "width": "10%", "orderable": false},
                {"title": "资讯来源", "data": "src", "width": "10%", "orderable": false},
                {"title": "浏览数", "data": "scanNum", "width": "6%", "orderable": false},
                {"title": "发布时间", "data": "deployTime", "width": "9%", "orderable": false},
                {"title": "状态", "data": "status", "width": "8%", "orderable": false},
                {"title": "操作", "data": null, "width": "17%", "orderable": false},
                {"title": "创建时间", "data": "createTime", "width": "10%", "orderable": false, "visible": false}
            ],
            "columnDefs": [
                {
                    "targets": 0,
                    "render": function (data, type, row, meta) {
                        if (row.image != null && row.image != ""){
                            return "<img src=" + row.image + " width='45px;' height='45px'/>";
                        }else {
                            return row.image;
                        }
                    }
                },
               /* {
                    "targets": 4,
                    "render": function (data, type, row, meta) {
                        if (row.scanNum > 0){
                            return "<a class='btn btn-xs default btn-editable' href='${ctx}/admin/info/scan/list?id=" + row.id + "'> "+row.scanNum+" </a>";
                        }else {
                            return "<a class='btn btn-xs default btn-editable' href='javascript:void(0)'> "+row.scanNum+" </a>";
                        }
                    }
                },

                {
                    "targets": 5,
                    "render": function (data, type, row, meta) {
                        if (row.evaluateNum > 0){
                            return "<a class='btn btn-xs default btn-editable' href='${ctx}/admin/info/eva/list?id=" + row.id + "'> "+row.evaluateNum+" </a>";
                        }else {
                            return "<a class='btn btn-xs default btn-editable' href='javascript:void(0)'> "+row.evaluateNum+" </a>";
                        }
                    }
                },*/
                {
                    "targets": 7,
                    "render": function (data, type, row, meta) {
                        var result =
                                "<a class='btn btn-xs default btn-editable' href='${ctx}/admin/info/edit?id=" + data.id + "'><i class='fa fa-pencil-square-o'></i> 编辑 </a>" +
                                "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/del' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-minus-square-o'></i> 删除 </a>";
                        if (data.status == 1) {
                            result += "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/grounding' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-external-link'></i> 发布 </a>";
                        } else {
                            result += "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/grounding' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-times-circle-o'></i> 取消发布 </a>";
                        }
                        if (data.isSuggest == 1) {
                            result += "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/grounding1' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-thumbs-o-up'></i> 推荐 </a>";
                        } else {
                            result += "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/grounding1' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-times-circle-o'></i> 取消推荐 </a>";
                        }
                        if (data.isHot == 1) {
                            result += "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/grounding2' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-thumbs-o-up'></i> 设为热点 </a>";
                        } else {
                            result += "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/info/grounding2' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-times-circle-o'></i> 取消热点 </a>";
                        }
                        return result;
                    }
                },
                {
                    "targets": 6,
                    "render": function (data) {
                        switch (data){
                            case 1:
                                return "未发布";
                            default :
                                return "已发布";
                        }
                    }
                },
            ],
            "order": [
                [8, "desc"]
            ]
        };
        /* Init DataTables */
        $('#data-table').DataTable(ehconfig.get_datatable_config(setting));
        submitFilter = function () {
            $('#data-table').DataTable().draw();

        }
    });
    //    function clean() {
    //        $('#begin_time1').val('');
    //        $('#begin_time2').val('');
    //        $('#type').val('');
    //        $('#data-table').DataTable().draw();
    //    }

</script>

</body>

</html>
